package com.peng.controller;

import com.peng.service.CommentService;
import com.peng.vo.Result;
import com.peng.vo.params.CommentParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comments")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 评论显示模块实现
     * @param articleId
     * @return
     */
    @GetMapping("article/{id}")
    public Result comment(@PathVariable("id")Long articleId){
        return commentService.commonsByArticleId(articleId);
    }

    /**
     * 发表评论
     */
    @PostMapping("create/change")
    public Result createComment(@RequestBody CommentParam commentParam){
        return commentService.createComment(commentParam);
    }
}
